package org.foreverframework.system.userweb.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.foreverframework.system.user.service.MenuService;
import org.foreverframework.system.user.service.UserService;
import org.foreverframework.system.user.service.UserServiceException;
import org.foreverframework.system.userweb.Activator;

public class LoginAction extends HttpServlet{
	private static final long serialVersionUID = 605084525972358889L;
	private UserService userService;
	private MenuService menuService;
	
	public void init() throws ServletException {
		userService = Activator.getService(UserService.class);
		menuService = Activator.getService(MenuService.class);
		System.out.println(menuService);
	}

	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String username = "admin";
		String password = "admin";
		try {
			userService.loginValidator(username, password);
			resp.getWriter().print("login success");
			//req.getRequestDispatcher("/system/userweb/view/index.html").forward(req, resp);
		} catch (UserServiceException e) {
			e.printStackTrace();
		}
	}
	
}
